      SUBROUTINE GETPRV ( N, PRIV )
C*
C*                  *******************************
C*                  *******************************
C*                  **                           **
C*                  **          GETPRV           **
C*                  **                           **
C*                  *******************************
C*                  *******************************
C*
C*     SUBPROGRAM :
C*          GET PRIVILEGES
C*
C*     AUTHOR :
C*          ART RAGOSTA
C*          MS 207-5
C*          AMES RESEARCH CENTER
C*          MOFFETT FIELD, CA  94035
C*          (415) 694-5578
C*
C*     PURPOSE :
C*          TO CHECK THE PRIVILEGES ALLOWED BY THE SYSUAF FILE AND
C*          RETURN THEM IN ASCII FORM.
C*
C*     INPUT ARGUMENTS :
C*          NONE
C*
C*     OUTPUT ARGUMENTS :
C*          N     - THE NUMBER OF PRIVILEGES FOUND
C*          PRIV  - THE ARRAY CONTAINING THE NAMES OF THE PRIVILEGES
C*
C*     INTERNAL WORK AREAS :
C*          MASK1, MASK2 - THE MASK BITS FOR THE PRIVILEGES
C*          ALL1, ALL2 - THE ASCII NAMES CORRESPONDING TO MASK1 AND MASK2
C*
C*     COMMON BLOCKS :
C*          NONE
C*
C*     FILE REFERENCES :
C*          NONE
C*
C*     SUBPROGRAM REFERENCES :
C*          JPI$_AUTHPRIV,  JPI$_CURPRIV, SYS$GETJPIW
C*
C*     ERROR PROCESSING :
C*          NONE
C*
C*     TRANSPORTABILITY LIMITATIONS :
C*          ABSOLUTELY NOT TRANSPORTABLE
C*
C*     ASSUMPTIONS AND RESTRICTIONS :
C*          NONE
C*
C*     LANGUAGE AND COMPILER :
C*          ANSI FORTRAN 77
C*
C*     VERSION AND DATE :
C*          VERSION I.0     12-APR-85
C*
C*     CHANGE HISTORY :
C*          12-APR-85    INITIAL VERSION
C*
C***********************************************************************
C*
      CHARACTER *(*) PRIV(1)
      CHARACTER *10 ALL1(32), ALL2(7)
      INTEGER *2 ITEM(2)
      INTEGER *4 MASK1(32), MASK2(7), ITMLST(3), QUAD(2)
      EQUIVALENCE (ITEM(1),ITMLST(1))
C
C --- ITEM CODES
C
      EXTERNAL JPI$_AUTHPRIV,   JPI$_CURPRIV
C
C --- PRIVILEGE NAMES IN THE FIRST QUADWORD
C
      DATA ALL1 /     'ACNT      ', 'ALLSPOOL  ', 'BUGCHK    ',
     $  'BYPASS    ', 'CMEXEC    ', 'CMKRNL    ', 'DETACH    ',
     $  'DIAGNOSE  ', 'EXQUOTA   ', 'GROUP     ', 'GRPNAM    ',
     $  'LOG_IO    ', 'MOUNT     ', 'NETMBX    ', 'OPER      ',
     $  'PFNMAP    ', 'PHY_IO    ', 'PRMCEB    ', 'PRMGBL    ',
     $  'PRMMBX    ', 'PSWAPM    ', 'SETPRI    ', 'SETPRV    ',
     $  'SHARE     ', 'SHMEM     ', 'SYSGBL    ', 'SYSLCK    ',
     $  'SYSNAM    ', 'SYSPRV    ', 'TMPMBX    ', 'VOLPRO    ',
     $  'WORLD     '/
C
C --- PRIVILEGE NAMES IN THE SECOND QUAD WORD
C
      DATA ALL2 /     'DOWNGRADE ', 'GRPPRV    ', 'PRMJNL    ',
     $  'READALL   ', 'SECURITY  ', 'TMPJNL    ', 'UPGRADE   '/
C
C --- MASK BITS FOR THE FIRST QUAD WORD
C
      DATA MASK1 /     512,          16,           8388608,
     $   536870912,    2,            1,            32,
     $   64,           524288,       256,          8,
     $   128,          131072,       1048576,      262144,
     $   67108864,     4194304,      1024,         16777216,
     $   2048,         4096,         8192,         16384,
     $   -2147483648,  134217728,    33554432,     1073741824,
     $   4,            268435456,    32768,        2097152,
     $   65536 /
C
C --- MASK BITS FOR THE SECOND QUAD WORD
C
      DATA MASK2 /     2,            4,            32,
     $   8,            64,           16,           1 /
C
      N = 0
C
C --- FILL ITMLST
C
      ITEM(1)   = 8
      ITEM(2)   = %LOC( JPI$_AUTHPRIV )
      ITMLST(2) = %LOC( QUAD(1) )
      ITMLST(3) = %LOC( LENG )
      ISTAT = SYS$GETJPIW ( ,,, ITMLST, IOSB,, )
C
C --- PROCESS FIRST WORD OF QUAD WORD
C
      DO 10 I = 1,32
         IF ((QUAD(1) .AND. MASK1(I)) .NE. 0) THEN
            N = N + 1
            PRIV(N) = ALL1(I)
         ENDIF
10       CONTINUE
C
C --- PROCESS SECOND WORD OF QUAD WORD
C
      DO 20 I = 1,7
         IF ((QUAD(2) .AND. MASK2(I)) .NE. 0) THEN
            N = N + 1
            PRIV(N) = ALL2(I)
         ENDIF
20       CONTINUE
      RETURN
      END
C
C---END GETPRV
C
